define(['app'], function(app) {
	'use strict';

	var controller = function controller($scope, Recruitmentbuild,GoPage, $window, $timeout, $ionicSlideBoxDelegate,$ionicModal) {
		$scope.isLoad = false; //可以加载
		//画面加载
		$scope.$on('$ionicView.afterEnter', function() {
			//动态设置高度
			var all = $window.innerHeight;
			//计算滚动条
			$scope.myObj = {
				"height": all - 44 + "px"
			};
		}, false);
		//滑动时候触发
		$scope.selectIndex = 0;
		$scope.slideChanged = function(index) {
			//手指滑动
			$scope.selectIndex = index;
		};
		$scope.activeSlide = function(index) {
			$scope.selectIndex = index;
			$ionicSlideBoxDelegate.$getByHandle('main-handle').slide(index);
		};
		//数据获取
		Recruitmentbuild.get_detail(function(data) {
			$scope.detail = data;
		});
		/************模态窗口*************/
		//新建地址
		$ionicModal.fromTemplateUrl('templates/modal/build.html', {
			scope: $scope
		}).then(function(modal) {
			$scope.modal = modal;
		});
		//离开主页面的时候一定要移除
		$scope.$on('$destroy', function() {
			$scope.modal.remove();
		});
		//编辑地址
		$scope.doAdd = function(item) {
			$scope.modal.show();
		};
		//关闭拟态
		$scope.doCancel = function() {
			$scope.modal.hide();
		};
		//保存数据
		$scope.doSave = function(data) {
			$scope.modal.hide();
		};
		//下拉刷新 判断哪个模块进行刷新
		$scope.doRefresh = function() {
			$timeout(function() {
				$scope.$broadcast('scroll.refreshComplete');
			}, 1000);
		};
		//加载更多
		$scope.doRefreshMore = function() {
			$timeout(function() {
				$scope.$broadcast('scroll.infiniteScrollComplete');
			}, 1000);
		};
		//促销
		$scope.onshow_detail = function(value) {
			GoPage.go_states("recruitmentdetail");
		};
	}

	controller.$inject = ['$scope', 'Recruitmentbuild','GoPage', '$window', '$timeout', '$ionicSlideBoxDelegate','$ionicModal'];

	return app.registerController("recruitmentbuildctrl",controller);
});